﻿/*
 * Created by SharpDevelop.
 * User: MARACUYA
 * Date: 17/11/2011
 * Time: 2:37
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

using Business_Entity;

namespace DAOFactory
{
	/// <summary>
	/// Description of DAORaza.
	/// </summary>
	public class DAORaza
	{
		public DAORaza()
		{
		}
		
		public List<BERaza> obtenerRazasMascotas(BEEspecie beEspecie)
		{
			SqlDataReader amd = null;
			List<BERaza> lista = new List<BERaza>();
			
			try{
				SqlCommand cmd = new SqlCommand("VENTAS_OBTENER_RAZA_MASCOTA_R", ConnectionManager.getConnection());
				cmd.CommandType = CommandType.StoredProcedure;
				
				cmd.Parameters.Add("@IDESPECIE", SqlDbType.Int);
				cmd.Parameters["@IDESPECIE"].Value = beEspecie.IdEspecie;
				
				amd = cmd.ExecuteReader();				
				
				if (amd.HasRows) 
				{					
					lista.Add(new BERaza(-1,"<Seleccionar>"));
					
					while(amd.Read())
					{
						BERaza raza = new BERaza();
						raza.IdRaza = int.Parse(amd[0].ToString());
						raza.Descripcion = amd[1].ToString();
						raza.BeEspecie = beEspecie;											
												
						lista.Add(raza);

					}
				}
			}
			catch(SqlException e){
				System.Windows.Forms.MessageBox.Show(e.ToString(),"Error");				
			}
			
			if(amd != null)
				amd.Close();
			return lista;
		}
	}
}
